var a = require("../../@babel/runtime/helpers/defineProperty"),
  t = require("../../res/www.a9a.cn.js"),
  e = getApp(),
  o = 2,
  n = !0,
  i = wx.getStorageSync("COOK_U");
Page({
  data: { topbar: ["余额", "明细", "充值"], currentTab: 0 },
  onLoad: function (a) {
    var o = this;
    e.chklogin().then(function (a) {
      a || wx.navigateBack();
    });
    var n = 2 == a.currentTab ? 2 : 0;
    e.get_openid().then(function (a) {
      o.setData({
        color: e._ZEAI.color,
        rgbcolor: t.c16_rgb(e._ZEAI.color),
        loveb_str: e._ZEAI.loveb,
        currentTab: n,
      }),
        wx.setNavigationBarTitle({ title: "我的" + e._ZEAI.loveb }),
        (i = wx.getStorageSync("COOK_U")),
        e.ajax({
          url: "my_loveb.php",
          data: { submitok: "loveb", openid: i.openid },
          success: function (a) {
            if (1 == a.flag) {
              if (a.CZ.list.length > 0) var t = ["余额", "明细", "充值"];
              else t = ["余额", "明细"];
              1 != a.ios_ifpay.flag &&
                wx.getSystemInfo({
                  success: function (a) {
                    "ios" == a.platform && (t = ["余额", "明细"]);
                  },
                }),
                o.setData({
                  loveb: a.cook_loveb,
                  CZ: a.CZ,
                  topbar: t,
                  ios_ifpay: a.ios_ifpay,
                });
            } else wx.showToast({ title: a.msg, icon: "none", mask: !0 });
          },
        });
    });
  },
  topbarFn: function (a) {
    var t = parseInt(a.currentTarget.dataset.idx);
    this.setData({ currentTab: t }), 1 == t && this.get_data();
  },
  get_data: function () {
    e.chklogin().then(function (a) {
      a || wx.navigateBack();
    }),
      (n = !1);
    var t = this,
      o = wx.getStorageSync("COOK_U");
    e.ajax({
      url: "my_loveb.php",
      data: { submitok: "list", openid: o.openid },
      success: function (e) {
        var o = e.LIST;
        if (1 == e.flag) {
          var i;
          if (
            (o.length >= 15 &&
              t.setData({ loading_flag: !0, loading_ico_flag: !0 }),
            0 == o.length)
          )
            t.setData(a({ loading_flag: !1 }, "nodatabox", !0));
          else
            t.setData(
              (a((i = {}), "LIST[0]", o),
              a(i, "nodatabox", !1),
              a(i, "loading_flag", !1),
              i)
            );
          n = !0;
        } else
          wx.showModal({
            content: e.msg,
            confirmColor: t.data.color,
            confirmText: "朕知道了",
            showCancel: !1,
            success: function (a) {
              wx.navigateBack();
            },
          });
      },
    });
  },
  onReachBottom: function () {
    if (0 != this.data.currentTab) {
      var t = this,
        s = this.data.LIST;
      n &&
        ((n = !1),
        t.setData({ loading_ico_flag: !0 }),
        e.ajax({
          url: "my_loveb.php",
          data: { submitok: "list", p: o, openid: i.openid },
          success: function (e) {
            var i = e.LIST;
            if (i.length < 1)
              return (
                t.setData({
                  loading_flag: !0,
                  loading_ico_flag: !1,
                  loading_str: "已全部加载完成",
                }),
                void (n = !1)
              );
            t.setData(a({}, "LIST[" + s.length + "]", i)), (o += 1), (n = !0);
          },
        }));
    }
  },
  czliFn: function (t) {
    var e = t.currentTarget.dataset.idx;
    this.setData(a({}, "CZ.defkey", e));
  },
  payFn: function () {
    var a = this,
      t = a.data.CZ,
      o = a.data.CZ.defkey;
    1 != a.data.ios_ifpay.flag
      ? wx.getSystemInfo({
          success: function (n) {
            "ios" == n.platform
              ? wx.showModal({
                  title: "温馨提示",
                  content: a.data.ios_ifpay.tips,
                  confirmColor: a.data.color,
                  cancelText: "返回",
                  confirmText: "联系服务人员",
                  success: function (a) {
                    a.confirm
                      ? wx.redirectTo({ url: "../my/hongniang" })
                      : a.cancel && wx.navigateBack();
                  },
                })
              : e.pay({
                  data: { submitok: "loveb_cz", rmb: t.list[o].rmb_yj },
                });
          },
        })
      : e.pay({ data: { submitok: "loveb_cz", rmb: t.list[o].rmb_yj } });
  },
});
